<?php

namespace App\EventHandler;

use App\Component\Curl;
use App\Core\Exception\DefaultException;
use App\Event\Event;
use App\Logic\Member\MemberService;
use EasySwoole\EasySwoole\Logger;

class CountUserHandler extends HandlerBase
{
    function handle()
    {
        Event::getInstance()->set(Event::EVENT_COUNT_USER, function (...$args) {
            Logger::getInstance()->info('处理用户统计信息事件');
            try {
                list($data) = func_get_args();
                MemberService::getInstance()->countUserData($data['userId']);
                return [
                    'result'  => true,
                    'message' => ''
                ];
            } catch (\Throwable $e) {
                return [
                    'result'  => false,
                    'message' => $e,
                ];
            }
        });
    }

}
